<template>
    <IDrawer v-model="defaultValue" :loading="loading" :width="400" title="生成波次">
        <Form :model="data" :label-width="100" :rules="ruleValidate" ref="formCreate">
            <Alert type="error" show-icon>系统会自动按产品顺序排序生成波次。</Alert>
            <Row>
                <FormItem label="订单类型" prop="type">
                    <RadioGroup v-model="data.type" type="button" size="small">
                        <Radio label="0">一单一品</Radio>
                        <Radio label="1">一单多品</Radio>
                    </RadioGroup>
                </FormItem>
            </Row>
            <FormItem label="客户名称" prop="customer_id">
                <RemoteSelect url="common/select/customer" v-model="data.customer_id"></RemoteSelect>
            </FormItem>
        </Form>
        <div slot="footer">
            <Button type="primary" icon="ios-add" long @click="submit('formCreate')">提交</Button>
        </div>
    </IDrawer>
</template>

<script>
    import IForm from "../../../components/content/form";
    import contentDrawer from "../../../mixins/contentDrawer";
    import IDrawer from "../../../components/content/modal";
    import RemoteSelect from "../../../components/form/remoteSelect";

    export default {
        name: "wellen",
        mixins: [contentDrawer],
        components: {RemoteSelect, IForm, IDrawer},
        data() {
            return {
                data: {},
                ruleValidate: {
                    customer_id: [{required: true, message: '客户必须填写!'}],
                    type: [{required: true, message: '订单类型必须选择!'}],
                }
            }
        },
        methods: {
            submit(data) {
                this.validate(data).then(() => {
                    this.loading = true;
                    this.$http.post(`order/shipment/auto`, this.data).then(() => {
                        this.defaultValue = false;
                    }).finally(() => {
                        this.loading = false;
                    });
                });
            }
        }
    }
</script>

<style scoped>

</style>
